package com.legendshop.openportal.sdk.model.request;

import com.legendshop.openportal.sdk.annotation.JsonValid;
import com.legendshop.openportal.sdk.model.BaseRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

import static com.legendshop.openportal.sdk.model.constants.ApiPathConstants.QUERY_PROD_STOCK;

/**
 * @Description: 商品价格查询
 * @Author lwj
 * @data 2024/7/1
 **/

@Data
@Accessors(chain = true)
public class ProdStockRequest extends BaseRequest {

    private static final long serialVersionUID = 8187695740776417325L;


    @NotNull(message = "省地区ID不能为空")
    @ApiModelProperty(value = "省地区ID")
    private Long province;

    @NotNull(message = "城市地区ID不能为空")
    @ApiModelProperty(value = "城市地区ID")
    private Long city;

    @NotNull(message = "区县地区ID不能为空")
    @ApiModelProperty(value = "区县地区ID")
    private Long area;

    @NotNull(message = "乡镇地区ID不能为空")
    @ApiModelProperty(value = "乡镇地区ID")
    private Long town;


    @NotBlank(message = "skuInfos库存查询对象不能为空,格式如下：[{\"prodId\": \"1249844\",\"skuId\": \"802504\", \"num\": 1}]")
    @JsonValid(target = ProdStockRequest.SkuInfo.class, isArrayJson = true, message = "skuInfos不是jsonArr类型字段， 格式如下：[{\"prodId\": \"1249844\",\"skuId\": \"802504\", \"num\": 1}]")
    private String skuInfos;


    @Data
    public static class SkuInfo implements Serializable {
        private static final long serialVersionUID = -8498370741983699232L;

        @NotNull(message = "产品Id不能为空")
        @ApiModelProperty(value = "产品Id")
        private Long prodId;

        @NotNull(message = "sku编码不能为空")
        @ApiModelProperty(value = "sku编码")
        private Long skuId;

        @ApiModelProperty(value = "sku数量")
        @NotNull(message = "sku数量不能为空")
        private Integer num;
    }


    @Override
    @ApiModelProperty(hidden = true)
    public String getApiPath() {
        return QUERY_PROD_STOCK;

    }
}
